package com.magold.sound;

import java.io.IOException;

import org.andengine.audio.music.Music;
import org.andengine.audio.music.MusicFactory;
import org.andengine.audio.music.MusicManager;
import org.andengine.ui.activity.BaseGameActivity;

public class BGM {
	private static String sBase = "mfx/";
	private BGM() {}
	
	/**
	 * 
	 * @param pContext
	 * @param pPath
	 * @return if success.
	 */
	public static Music play(BaseGameActivity pContext, String pPath) {
		MusicManager mm = pContext.getMusicManager();
		try {
			Music music = MusicFactory.createMusicFromAsset(mm, pContext, sBase + pPath);
			music.setLooping(true);
			music.play();
			return music;
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}
}
